package com.bsoft.quartz;


import com.bsoft.service.HivPushService;
import com.bsoft.service.InvoicingBoozService;
import com.bsoft.service.ReportQueryService;
import com.bsoft.service.impl.ReportQueryServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.xml.crypto.Data;


/*
 * fixedRate是按照固定的时间间隔（从任务开始的时间点计算）来执行任务的，
 * 而fixedDelay则是从上一次任务执行完成的时间点开始计算延迟时间。
 */

@Component
public class ScheduledPutreslist {
    private static Logger logger = LoggerFactory.getLogger(ScheduledPutreslist.class);
    @Value("${initiateFlag}")
    private String initiateFlag;

    @Value("${hivPushProviceLOg}")
    private String hivPushProviceLOg;

    @Value("${dzfpSchTask.enable}")
    private boolean dzfpEnable;


    @Resource
    private ReportQueryService reportQueryService;

    @Resource
    private HivPushService hivPushService;

    @Autowired
    private InvoicingBoozService invoicingBoozService;


    //成华锦电检查报告回传his
    @Scheduled(initialDelay = 1 * 1000, fixedDelayString = "${dzpjSCTime}")
    public void getJCBG() {
        if ("1".equals(initiateFlag)) {
            reportQueryService.getJCBG();
        }

    }


    //HIV上传省平台 @Scheduled(fixedRate = 300000)
    @Scheduled(initialDelay = 1 * 1000, fixedDelayString = "${hivSCTime}")
    public void push_HIVProvincePt() {
        if ("1".equals(hivPushProviceLOg)) {
            try {
                hivPushService.hivPush_ProvincePt();
            } catch (Exception e) {
                logger.error("HIV上传省平台异常:", e);
            }
        }
    }

    //HIHIS电子票据定时上传.只上传没有开票的
    @Scheduled(initialDelay = 5 * 1000, fixedDelayString = "${dzfpSchTask.pushTiem}")
    public void invoiceEBillAll() {
        logger.info("进入电子发票自动补传");
        if (dzfpEnable) {
            invoicingBoozService.invoiceEBillAll();
        }
    }
}
